﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MicropleSoft.Controls.DialogBox;
using MicropleSoft.WmsApp.Library.ServiceFacade;

namespace MicropleSoft.Controls.ComplexControl
{
    public partial class CDialogLookUpEdit : MicropleSoft.Controls.ComplexControl.CBaseComplexControl, IComplexDataBinder
    {
        public delegate void CDialogLookUpEditClickEventHandler(
            out object dataSource, out List<LookUpViewHeader> lookUpViewHeaders);

        public event CDialogLookUpEditClickEventHandler CDialogLookUpEditClick = null;
        public CDialogLookUpEdit()
        {
            InitializeComponent();
        }

        private void CmdPreview_Click(object sender, EventArgs e)
        {
            if(CDialogLookUpEditClick != null)
            {
                object dataSource = null;
                List<LookUpViewHeader> lookUpViewHeaders = null;
                CDialogLookUpEditClick(out dataSource, out lookUpViewHeaders);
                var form = new FormCDialogLookUpEdit();
                if(DialogResult.OK == form.ShowDialog())
                {
                    this.EditValue = form.ResultValue;
                }
            }
            else
            {
                CustomMessageBox.ShowError("请注册该控件的事件：" + "CDialogLookUpEditClick");
            }

        
        }

        public object EditValue
        {
            get
            {
                return this.xTextEditText.EditValue;
            }
            set
            {
                this.xTextEditText.EditValue = value;
            }
        }

        public void ExcuteDataBinding(WmsApp.Library.IBaseDomainObject baseDomainObject)
        {
            this.xTextEditText.ExcuteDataBinding(baseDomainObject);
        }

        public bool IsPrimaryKey
        {
            get
            {
                return this.xTextEditText.IsPrimaryKey;
            }
            set
            {
                this.xTextEditText.IsPrimaryKey = value;
            }
        }

        public bool ReadOnly
        {
            get
            {
                return this.xTextEditText.ReadOnly;
            }
            set
            {
                this.xTextEditText.ReadOnly = value;
            }
        }

        public string PropertyName
        {
            get
            {
                return this.xTextEditText.PropertyName;
            }
            set
            {
                this.xTextEditText.PropertyName = value;
            }
        }
    }
}
